This rule is a more precise version of S1308 preventing the use of GO TO
. The flow of a program is already complicated to
understand with simple GO TO
s. It’s even worse when a GO TO
is executed conditionally like this is the case with GO TO
DEPENDING ON
.
Noncompliant code example
PROCEDURE DIVISION.
...
GO TO PARAGRAPH-10
PARAGRAPH-20
PARAGRAPH-30
DEPENDING ON WS-PARA-NUMBER *> Noncompliant
...
Compliant solution
PROCEDURE DIVISION.
...
EVALUATE WS-PARA-NUMBER
WHEN 1
PERFORM PARAGRAPH-10
WHEN 2
PERFORM PARAGRAPH-20
WHEN 3
PERFORM PARAGRAPH-30
WHEN OTHER
PERFORM PARAGRAPH-99
END-EVALUATE
...